<template>
  <div class="box_b">
    <h1 class="title">四川君百名科技有限公司</h1>
    <div class="register">
      <h1>修改密码</h1>
      <div class="register_r">
        <span>账号:</span>
        <el-input type="text" v-model="username" placeholder="请输入您的账号" />
      </div>
      <div class="register_r">
        <span>密码:</span>
        <el-input
          placeholder="请输入密码"
          v-model="password"
          show-password
        ></el-input>
      </div>
      <div class="register_r">
        <span>修改:</span>
        <el-input
          placeholder="请输入修改后的密码"
          v-model="password1"
          show-password
        ></el-input>
      </div>
      <div class="register_r">
        <span>重复:</span>
        <el-input
          placeholder="请重复输入修改后的密码"
          v-model="password2"
          show-password
        ></el-input>
      </div>

      <button class="register_i" @click="clickToChange">修改</button>
    </div>
  </div>
</template>

<script>
import { _changePwd } from "@/request";

export default {
  data() {
    return {
      username: "",
      password: "",
      password1: "",
      password2: "",
      token: "",
    };
  },
  mounted() {
    const token = this.$route.query.token;
    this.token = token;
    // console.log(this.token);
    // 大写小写 数字  6-18
  },
  methods: {
    clickToChange() {
      if (this.password1 !== this.password2) {
        alert("两次输入的密码不一致！");
        return;
      }

      const formData = new FormData();
      formData.append("oldpsw", this.password);
      formData.append("password", this.password2);

      const config = {
        Token: ` ${this.token}`,
      };

      _changePwd(formData, config)
        .then((res) => {

          if (res.data.code === 500) {
            alert(res.data.msg);
          }
        })
        .catch((error) => {
          console.log(error);
        });
    },
  },
};
</script>

<style lang="less" scoped>
.box_b {
  width: 100vw;
  height: 100vh;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: linear-gradient(0deg, rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0.2));
  background-image: url("/src/img/bgi.jpg");
  background-size: cover;
  // display: flex;
  // justify-content: space-around;
}

.box_b .title {
  color: #fff;
  font-size: 3vw;
  letter-spacing: 0.5vw;
  text-shadow: 0 0 5px rgba(255, 255, 255, 0);
  animation: fadeInAndColorChange 2s ease-in-out forwards,
    scaleUp 2s ease-in-out forwards;
  margin: 15vh 0 0 32vw;
  display: inline-block;
  cursor: pointer;
  z-index: -1;
  -webkit-user-select: none; /* Safari */
  -moz-user-select: none; /* Firefox */
  -ms-user-select: none; /* IE10+/Edge */
  user-select: none;
}

@keyframes fadeInAndColorChange {
  0% {
    opacity: 0;
    color: rgba(0, 0, 0, 0.5);
    text-shadow: 0 0 5px rgba(255, 255, 255, 0);
  }
  100% {
    opacity: 1;
    color: #fff;
    text-shadow: 0 0 10px gray;
  }
}

@keyframes scaleUp {
  0% {
    transform: scale(0.95);
  }
  100% {
    transform: scale(1.55);
  }
}
.box_b::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  background-color: rgba(255, 255, 255, 0.5); /* 白色遮罩层，透明度0.5 */
}

.box_b img {
  width: 500px;
  height: 550px;
}

.register {
  width: 480px;
  height: 400px;
  background-color: #e0e0ef;
  margin: 15vh 0 0 40vw;
}

.register h1 {
  text-align: center;
  line-height: 80px;
}

.register span {
  font-size: 20px;
}

.register_r {
  width: 100%;
  display: flex;
  justify-content: space-evenly;
  line-height: 60px;
  text-align: center;
  align-items: center;
}

.register_r .el-input {
  width: 300px;
  height: 35px;
  outline: none;
  padding-left: 10px;
  border: none;
}

.register_i {
  background-color: #298dfb;
  width: 84%;
  line-height: 50px;
  color: #fff;
  margin-top: 5%;
  border-radius: 5px;
  text-align: center;
  margin-left: 8%;
  border: 1px #e4e7ed ridge;
  font-size: 20px;
  cursor: pointer;
}

#c1 {
  vertical-align: middle;
  box-sizing: border-box;
  cursor: pointer;
  margin-right: 10px;
}
</style>
